<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/9
 * Time: 8:42
 */

namespace app\admin\controller;
use app\admin\common\Base;
use think\facade\Request;

class Site extends Base
{
    public function index(){
        if (Request::isPost()){
            $data = Request::post();
            $id = $data['id'];
            if($id){
                unset($data['id']);
                $data['update_time'] = time();
                $res = \app\admin\model\Site::where('id',$id)->update($data);
            }else{
                $data['create_time'] = time();
                $res = \app\admin\model\Site::create($data);
            }
            if ($res){
                return $this->success('保存成功');
            }
            return $this->error('保存成功');
        }
        $siteInfo = \app\admin\model\Site::get(['status'=>1]);
        $this->assign('siteInfo', $siteInfo);
        return $this->view->fetch();
    }
}